function routerResponse(option = {}) {
	return async function(ctx, next) {
		ctx.success = function({
			data,
			msg,
			code
		}) {
			ctx.body = {
				code: code || 200,
				msg: msg || 'success',
				data: data
			}
		}
		ctx.fail = function({
			msg,
			code
		}) {
			ctx.body = {
				code: code || 400,
				msg: msg || 'fail',
			}
		}
		try {
			await next()
		} catch (err) {
			console.log('err--',err)
			ctx.body = {
				code: err.status || 500,
				msg: err.message,
			}
		}

	}

}
module.exports = routerResponse
